package helloworld.demo.consumer.ConsumerService;
import org.apache.servicecomb.provider.pojo.RpcReference;
import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import provider.service.HelloWorldService;

@RestSchema(schemaId = "consumer") // 该注解声明这是一个REST接口类，CSEJavaSDK会扫描到这个类，根据它的代码生成接口契约
@RequestMapping(path = "/consumer/v0") // @RequestMapping是Spring的注解，这里在使用Spring MVC风格开发REST接口

public class ConsumerService {
    @RpcReference(microserviceName = "provider",schemaId = "helloWorld")
    private HelloWorldService helloWorldService;

    @RequestMapping(path = "/hello", method = RequestMethod.GET)
    public String hello(@RequestParam(value = "name") String name) {
        return helloWorldService.hello(name);
    }
}
